package com.itheima.day20.demo06;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Random;

/**
 * 3. 随机点名器案例.
 * //提示: 高效的字符流一次读写一行.
 */
public class demo03 {
    public static final String SRC = "./homework/src/com/itheima/day20/demo06/student.txt";

    //public static final String DEST="./homework/src/com/itheima/day20/demo06/student.txt";
    public static void main(String[] args) throws Exception {
        ArrayList<String> list = new ArrayList<>();
        BufferedReader br = new BufferedReader(new FileReader(new File(SRC)));
        String s = null;
        while ((s = br.readLine()) != null) {
            list.add(s);
        }
        for (String s1 : list) {
            System.out.println(s1);
        }
        Random r = new Random();
        for (int i = 0; i < 100; i++) {
            System.out.println(list.get(r.nextInt(list.size())));
        }
        br.close();
    }
}
